package io.jnet.common.api.impl;

import java.nio.channels.AsynchronousSocketChannel;
import java.util.concurrent.BlockingQueue;
import com.jfireframework.baseutil.collection.buffer.ByteBuf;
import io.jnet.common.api.ChannelContext;
import io.jnet.common.decodec.FrameDecodec;
import io.jnet.common.streamprocessor.ProcessorTask;
import io.jnet.common.util.AioListener;

public class ConcentrationReadHandler extends AbstractReadHandler
{
    private final BlockingQueue<ProcessorTask> tasks;
    
    public ConcentrationReadHandler(BlockingQueue<ProcessorTask> tasks, AsynchronousSocketChannel socketChannel, FrameDecodec frameDecodec, ByteBuf<?> ioBuf, AioListener channelListener, ChannelContext serverChannelContext)
    {
        super(socketChannel, frameDecodec, ioBuf, channelListener, serverChannelContext);
        this.tasks = tasks;
    }
    
    @Override
    protected void process(ByteBuf<?> buf) throws Throwable
    {
        tasks.offer(new ProcessorTask(buf, 0, channelContext));
    }
    
}
